lights = {}
material = {}
model = {}
entity = {}
steps = {}

-- Light Set UP

lights[1]  = {
		pos = {0.000, 5.000, 0.000 },
		col = {64.0, 64.0, 64.0 },
		id = 1,
		intensity = 1.0
}
lights[2] = {
		pos = {-15.000, 8.000, -0.000 },
		col = {64.0, 0.0, 0.0 },
		id = 2,
		intensity = 1.0
}

lights[3] = {
		pos = {15.000, 8.000, -0.000 },
		col = {64.0, 0.0, 64.0 },
		id = 3,
		intensity = 1.0
}

lights[4] = {
		pos = {0.000, 8.000, -15.000 },
		col = {0.0, 64.0, 0.0 },
		id = 4,
		intensity = 1.0
}

lights[5] = {
		pos = {0.000, 20.000, 15.000 },
		col = {64.0, 64.0, 0.0 },
		id = 5,
		intensity = 1.0
}

-- Loading Models That can be reused
-- For instance bead leg - one model many instances

model[1] = {
	Name ="headboard",
	Model = "Headboard-n.obj"
}

model[2] = {
	Name ="footboard",
	Model = "Footboard-n.obj"
}

model[3] = {
	Name ="siderail",
	Model = "Siderail-n.obj"
}


model[4] = {
	Name ="plane",
	Model = "plane.obj"
}

-- Entity of the model

entity[1] = 
{
	id = 1,
	Model = "headboard",
	StartPosition = {-10.0, 0.0, 0.0},
	StartRotation = {0.0, 0.0, 0.0},
	EndPosition = {0.0, 0.0, 0.0},
	EndRotation = {360.0, 360.0, 360.0},
	Scale = { 0.1, 0.1, 0.1}
}

entity[2] = 
{
	id = 2,
	Model = "footboard",
	StartPosition = {10.0, 0.0, 0.0},
	StartRotation = {0.0, 0.0, 0.0},
	EndPosition = {0.0, 0.0, 0.0},
	EndRotation = {360.0, 360.0, 360.0},
	Scale = { 0.1, 0.1, 0.1}
}

entity[3] = 
{
	id = 3,
	Model = "siderail",
	StartPosition = {0.0, -10.0, -10.0},
	StartRotation = {0.0, 0.0, 0.0},
	EndPosition = {0.0, 0.0, 0.0},
	EndRotation = {360.0, 360.0, 360.0},
	Scale = { 0.1, 0.1, 0.1}
}

entity[4] = 
{
	id = 4,
	Model = "siderail",
	StartPosition = {0.0, 10.0, 10.0},
	StartRotation = {0.0, 0.0, 0.0},
	EndPosition = {0.0, 0.0, 0.0},
	EndRotation = {360.0, 360.0, 360.0},
	Scale = { 0.1, 0.1, 0.1}
}


entity[5] = 
{
	id = 5,
	Model = "plane",
	StartPosition = {0.0, 0.0, 0.0},
	StartRotation = {0.0, 180.0, 0.0},
	EndPosition = {0.0, 0.0, 0.0},
	EndRotation = {360.0, 360.0, 360.0},
	Scale = { 0.05, 0.05, 0.05}
}


-- material manager kinda thing

material[1] = {
	name = "wood",
	texture = "redwood.tga",
	normal = "redwood-normal.tga",
	ambient_color = { 0.5, 0.5, 0.5},
	difuse_color = {0.3, 0.3, 0.3}
}

material[2] = {
	name = "bottom",
	texture = "rockwall-2.tga",
	normal = "rockwall_normal-2.tga",
	ambient_color = { 0.5, 0.5, 0.5},
	difuse_color = {0.3, 0.3, 0.3}
}

-- steps 
steps[1] = {
	id = 1,
	action = "new", 	-- new, rotate, move, remove, clear (?)
	entity = 1, 		-- entity id that we want to operate with
	axis = "y", 		-- x,y,z - y is up
	value = 0 			
}

steps[2] = {
	id = 2,
	action = "rotate", 	-- new, rotate, move, remove, clear (?)
	entity = 1, 		-- entity id that we want to operate with
	axis = "y", 			-- x,y,z - y is up
	value = 180 			-- any value
}

steps[3] = {
	id = 3,
	action = "move", 	-- new, rotate, move, remove, clear (?)
	entity = 1, 		-- entity id that we want to operate with
	axis = "y", 			-- x,y,z - y is up
	value = 4.15 			-- any value
}

steps[4] = {
	id = 4,
	action = "new", 	-- new, rotate, move, remove, clear (?)
	entity = 2, 		-- entity id that we want to operate with
	axis = "y", 			-- x,y,z - y is up
	value = 0 			-- any value
}

steps[5] = {
	id = 5,
	action = "move", 	-- new, rotate, move, remove, clear (?)
	entity = 2, 		-- entity id that we want to operate with
	axis = "y", 			-- x,y,z - y is up
	value = 4 			-- any value
}

steps[6] = {
	id = 6,
	action = "new", 	-- new, rotate, move, remove, clear (?)
	entity = 3, 		-- entity id that we want to operate with
	axis = "y", 			-- x,y,z - y is up
	value = 0 			-- any value
}

steps[7] = {
	id = 7,
	action = "move", 	-- new, rotate, move, remove, clear (?)
	entity = 3, 		-- entity id that we want to operate with
	axis = "y", 			-- x,y,z - y is up
	value = 13.5 			-- any value
}

steps[8] = {
	id = 8,
	action = "new", 	-- new, rotate, move, remove, clear (?)
	entity = 4, 		-- entity id that we want to operate with
	axis = "y", 			-- x,y,z - y is up
	value = 0 			-- any value
}

steps[9] = {
	id = 9,
	action = "move", 	-- new, rotate, move, remove, clear (?)
	entity = 4, 		-- entity id that we want to operate with
	axis = "-y", 			-- x,y,z - y is up
	value = 6.5 			-- any value
}

steps[10] = {
	id = 10,
	action = "move", 	-- new, rotate, move, remove, clear (?)
	entity = 1, 		-- entity id that we want to operate with
	axis = "-x", 			-- x,y,z - y is up
	value = 6 			-- any value
}

steps[11] = {
	id = 11,
	action = "move", 	-- new, rotate, move, remove, clear (?)
	entity = 2, 		-- entity id that we want to operate with
	axis = "-x", 			-- x,y,z - y is up
	value = 6 			-- any value
}


steps[12] = {
	id = 12,
	action = "move", 	-- new, rotate, move, remove, clear (?)
	entity = 3, 		-- entity id that we want to operate with
	axis = "z", 			-- x,y,z - y is up
	value = 7.5 			-- any value
}

steps[13] = {
	id = 13,
	action = "move", 	-- new, rotate, move, remove, clear (?)
	entity = 4, 		-- entity id that we want to operate with
	axis = "-z", 			-- x,y,z - y is up
	value = 7.5 			-- any value
}



function initWorld()

	io.write("LUA: init World Baby!\n");
	
	
	io.write("LUA: adding Materials.. ");
	for i=1,table.getn(material) do
		addMaterial(material[i].name, material[i].texture, material[i].normal,  material[i].ambient_color[1], material[i].ambient_color[2], material[i].ambient_color[3], material[i].difuse_color[1], material[i].difuse_color[2], material[i].difuse_color[3] );
	end
	io.write("Done!\n");
	
	
	io.write("LUA: adding Lights.. ");
	
	for i=1,table.getn(lights) do
		addLight(lights[i].pos[1], lights[i].pos[2], lights[i].pos[3], lights[i].col[1], lights[i].col[2], lights[i].col[3], lights[i].intensity, lights[i].id);
	end
	io.write("Done!\n");
	
	io.write("LUA: adding Objects to Resources.. ");
	for i=1,table.getn(model) do
		addObject(model[i].Name, model[i].Model, model[i].Material);  
	end
	io.write("Done!\n");
	io.write("LUA: adding Entities to Scene.. ");
	for i=1,table.getn(entity) do
		addEntity(entity[i].id, entity[i].Model, entity[i].StartPosition[1], entity[i].StartPosition[2], entity[i].StartPosition[3], entity[i].EndPosition[1], entity[i].EndPosition[2], entity[i].EndPosition[3], entity[i].StartRotation[1], entity[i].StartRotation[2], entity[i].StartRotation[3], entity[i].EndRotation[1], entity[i].EndRotation[2], entity[i].EndRotation[3], entity[i].Scale[1], entity[i].Scale[2], entity[i].Scale[3]);  
	end
	io.write("Done!\n");
	
	io.write("LUA: add steps..");
	for i = 1, table.getn(steps) do
		addAction(steps[i].id, steps[i].action, steps[i].entity, steps[i].axis, steps[i].value);
	end
	
	io.write("Done!\n");
	
end

